package beanstao.util.store;

import beanstao.util.Sber;
import beanstao.util.enums.operator.Comparison;
import beanstao.util.enums.operator.Logical;

public class KVItem
{
	private Comparison comparison;
	private String key;
	private Object value;
	private Logical logical;

	public Logical $Logical()
	{
		return logical;
	}

	public Comparison $Comparison()
	{
		return comparison;
	}

	public String $Key()
	{
		return key;
	}

	public Object $Value()
	{
		return value;
	}

	public void setComparison(Comparison comparison)
	{
		this.comparison = comparison;
	}

	public void setKey(String key)
	{
		this.key = key;
	}

	public void setValue(Object v)
	{
		value = v;
	}

	public void setLogical(Logical logical)
	{
		this.logical = logical;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (this.getClass() != obj.getClass())
			return false;
		KVItem other = (KVItem) obj;
		if (comparison != other.comparison)
			return false;
		if (key == null)
		{
			if (other.key != null)
				return false;
		}
		else if (!key.equals(other.key))
			return false;
		if (logical != other.logical)
			return false;
		if (value == null)
		{
			if (other.value != null)
				return false;
		}
		else if (!value.equals(other.value))
			return false;
		return true;
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ((comparison == null) ? 0 : comparison.hashCode());
		result = prime * result + ((key == null) ? 0 : key.hashCode());
		result = prime * result + ((logical == null) ? 0 : logical.hashCode());
		result = prime * result + ((value == null) ? 0 : value.hashCode());
		return result;
	}

	@Override
	public String toString()
	{
		Sber sber = Sber.ME(this.$Key()).append(Comparison.toString(this.$Comparison())).append(this.$Value());
		return sber.toString();
	}
}
